<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
	{
		\App\Models\User::observe(\App\Observers\UserObserver::class);
		\App\Models\RedeemLog::observe(\App\Observers\RedeemLogObserver::class);
		\App\Models\PrizeRecord::observe(\App\Observers\PrizeRecordObserver::class);
		\App\Models\Prize::observe(\App\Observers\PrizeObserver::class);
		\App\Models\Filiale::observe(\App\Observers\FilialeObserver::class);
        \App\Models\Company::observe(\App\Observers\CompanyObserver::class);
        \App\Models\Product::observe(\App\Observers\ProductObserver::class);

        \Carbon\Carbon::setLocale('zh');
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        \API::error(function (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) {
            abort(404);
        });

        \API::error(function (\Illuminate\Auth\Access\AuthorizationException $exception) {
            abort(403, $exception->getMessage());
        });

    }
}
